package com.luzhikun.xianLiva;

import java.util.Objects;

/**
 * @author shkstart
 * @create 2021-03-14 20:23
 */
public class Product {
    private int proId;
    private String name;
    private int maxPrice;
    private int nowPrice;
    private Integer minprice;

    @Override
    public String toString() {
        return name + "   " + nowPrice;
    }

    public int getProId() {
        return proId;
    }

    public void setProId(int proId) {
        this.proId = proId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMaxPrice() {
        return maxPrice;
    }

    public void setMaxPrice(int maxPrice) {
        this.maxPrice = maxPrice;
    }

    public Integer getNowPrice() {
        return nowPrice;
    }

    public void setNowPrice(Integer nowPrice) {
        this.nowPrice = nowPrice;
    }

    public int getMinprice() {
        return minprice;
    }

    public void setMinprice(int minprice) {
        this.minprice = minprice;
    }

    public Product() {
    }

    public Product(int proId, String name, int maxPrice, int minprice) {
        this.proId = proId;
        this.name = name;
        this.maxPrice = maxPrice;
        this.minprice = minprice;
    }

    //随机商品价格
    public void randomNowPrice() {
        this.nowPrice = (int) (Math.random() * (maxPrice - minprice + 1) + minprice);

    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Product)) return false;
        Product product = (Product) o;
        return getProId() == product.getProId();
    }

    @Override
    public int hashCode() {
        return Objects.hash(getProId(), getName(), getMaxPrice(), getMinprice());
    }
}
